package br.com.framework.client.permissao.entidade;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "TELA")
public class Tela implements EntityGeneric {

	private static final long serialVersionUID = -4164075495658709035L;

	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TELA_SEQ_ID")
	@SequenceGenerator(name = "TELA_SEQ_ID", sequenceName = "TELA_SEQ_ID", allocationSize = 1)
	private Integer id;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tela")
	Set<GrupoTela> grupoTela = new HashSet<GrupoTela>();

	@Column(name = "NOME")
	private String nome;

	@Column(name = "PATH")
	private String path;

	@Transient
	private boolean selected;

	public Tela() {

	}

	public Tela(Tela tela) {
		setId(tela.getId());
		setGrupoTela(tela.getGrupoTela());
		setNome(tela.getNome());
		setPath(tela.getPath());
		setSelected(tela.isSelected());
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Set<GrupoTela> getGrupoTela() {
		return grupoTela;
	}

	public void setGrupoTela(Set<GrupoTela> grupoTela) {
		this.grupoTela = grupoTela;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

}